<?php echo $header; ?>
<div role="main" id="main"> 
            <section id="container">
            	<!-- breadcumbs-->
                <div id="breadcumbs">
                    <ol class="breadcumbs">
                        <?php for ($i=0;$i<sizeof($breadcrumbs);$i++) { ?>
                           
                            
                            <?php if($i+1==sizeof($breadcrumbs)) { ?>
                                 <li class="item current"><?php echo $breadcrumbs[$i]['text']; ?></li>
                            <?php } else { ?>
                            	<?php if($i==0) { ?>
                                	<li class="first root">
                                        <a href="<?php echo $breadcrumbs[$i]['href']; ?>">
                                            
                                        </a>
                               		</li>
                                <?php } ?>
                                <?php if($i==1) { ?>
                                	<li class="first root-cate"><?php echo $breadcrumbs[$i]['text']; ?></li>
                                <?php } ?>
                                <?php if($i>1) { ?>
                                	<li class="first child-cate"><?php echo $breadcrumbs[$i]['text']; ?></li>
                                <?php } ?>
                            <?php } ?>
                        <?php } ?>
                    </ol>
                </div>
                <!-- /breadcumbs-->
                
                <!--Banner-->
                <div class="page-banner">
                	<img alt="" src="catalog/view/theme/default/medias/slideshow/search-banner.jpg">
                    <span class="banner-title"><?php echo $text_banner;?></span>
                </div>
                <!--/Banner-->
                
                <div class="heading-tt">
                    <h1 class="fll"><span><?php echo $text_title_search;?>: <strong><?php echo $filter_name;?></strong></span></h1>
                    <strong class="search-info flr"><?php echo $total_search;?> <?php echo $text_title_result_search;?></strong>
                </div>

            	<div class="overlay-group group">
                	
                    <ul class="product-list">
                  		<?php if(isset($products) && count($products) > 0) {
                        foreach($products as $rs) {
                        ?>
                    	<li class="overlay-block">
                        	<a class="img-product" href="<?php echo $rs['href'];?>"><div class="overlay" style="opacity: 0;"></div>
                            
                         		<?php
                                    if($rs['special']) {
                                ?>
                                                    <p class="promo-tag">
                                                        <span class="minus">-</span>
                                                        <span class="discount-num"><?php echo ($rs['price_percent']);?></span>
                                                        <span class="percent">%</span>
                                                    </p>
                                <?php 
                                    }
                                ?>
                                <p>
                                    <span class="prd-name"><?php echo $rs['name_short'];?></span>
                                    <span class="price flr"><?php if($rs['special']) {echo $rs['special'];} else { echo $rs['price'];} ?></span>
                                </p>
                                <img src="timthumb.php?src=<?php echo $rs['image'];?>&w=295&h=230" alt="<?php echo $rs['name'];?>" />
                            </a>
                        </li>
                        <?php 
                        	} 
                        }
                        ?>
                    </ul>
                    
                    <!-- Pager-->
                    <div class="pager">
                    	<div class="pager-inner flr">
                            
                            <?php if(count($products) > 0) echo $pagination;?>
                            
                    	</div>
                    </div>
                    <!-- /Pager-->
                    
                    
                </div>
            </section>
        </div>
<?php echo $footer; ?>
<?php return;?>


<?php echo $header; ?>
		<div class="shop" id="main">
            <!-- / start main content -->  
            <div id="content" class="prd-category fl-right">
                <?php //echo $mebuu_about_home; ?>
                
               <!-- Breadcumbs  -->
                            	<div id="breadcumbs" class="fl-left">
                                	<ul id="crumbs">
                                        <li><a href=".">Trang chủ</a></li>
                                        <li><span>Kết quả tìm kiếm</span></li>
                                    </ul>
                                </div>
                                <!-- /Breadcumbs  -->
                               <div id="prdListInCat">
                                	<h2 class="tt-h2"><?php echo $total_search;?> sản phẩm được tìm thấy cho từ khóa tìm kiếm: <strong><?php echo $filter_name; ?></strong></h2>
                                    <ul class="prd-list">
    
                                    <?php								
                                     if(isset($products) && sizeof($products) > 0) {
                                    foreach($products as $rs) {
                                    ?>  
                                        <li>
                                            <a class="thumb tip" title="<?php echo $rs['name'];?>" href="<?php echo $rs['href'];?>"><img src="<?php echo $rs['image'];?>" alt="<?php echo $rs['name'];?>" /></a>
                                            <a class="prd-tt" href="<?php echo $rs['href'];?>"><?php echo $rs['name'];?></a>
                                            <p class="rating">
                                                <span class="min-rating-star inline-block">
                                                    <span class="min-rating-star rated" style="width: <?php echo ($rs['ratingproduct']+1)*20; ?>%;"></span>
                                                </span>
                                            </p>
                                                                        
                                            <p class="price">
                                            Giá : 
                                            <?php
                                             if($rs['price']>0) { 
                                            ?>
                                            <strong><?php echo $rs['price'];?></strong>
                                            <?php 
                                            } else {
                                            ?>
                                            <?php echo $chuacogia;?>
                                            <?php
                                            }
                                            ?>
                                            </p>
                                            <?php if((int)$rs['is_new'] == 1) {?>
                                            <span class="new"><img src="catalog/view/theme/default/img/new.png" alt="Mới" /></span>
                                            <?php }?>
                                        </li>
                                        
                                      <?php } }
                                      
                                     ?>                               
                                    </ul>
                                    <?php if (isset($pagination)) {?>
                                    <div class="category-nav bottom">
                                    	
                                        <div class="pager">
                                        	<span class="prd-stat"><?php echo $total_search;?> sản phẩm /</span>
                                            <span class="prd-page">Trang :</span>
                                        	<!-- enable this line if the current page is the last
                                            <a class="page-first link-btn">Trang trước</a>
                                            -->
                                        	<?php echo $pagination;?>
                                        </div>
                                        
                                    </div>
                                    <?php } ?>
                                    
                                </div>
                 
             </div>
            <!-- sidebar -->
            <div id="sidebar" class="fl-left">
                <?php echo $mebuu_category_about; ?>
                <?php echo $mebuu_left_info_shop; ?>
                
                <?php echo $mebuu_supportonline_home; ?>
                
                <?php echo $mebuu_right_info_transport_home; ?>     
            </div>
        <!-- / end main content -->    
   		</div>
     </div>   
<?php echo $footer; ?>




<?php return;?>
<?php echo $header; ?><?php echo $column_left; ?><?php echo $column_right; ?>
<div id="content"><?php echo $content_top; ?>
  <div class="breadcrumb">
    <?php foreach ($breadcrumbs as $breadcrumb) { ?>
    <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
    <?php } ?>
  </div>
  <h1><?php echo $heading_title; ?></h1>
  <b><?php echo $text_critea; ?></b>
  <div class="content">
    <p><?php echo $entry_search; ?>
      <?php if ($filter_name) { ?>
      <input type="text" name="filter_name" value="<?php echo $filter_name; ?>" />
      <?php } else { ?>
      <input type="text" name="filter_name" value="<?php echo $filter_name; ?>" onclick="this.value = '';" onkeydown="this.style.color = '000000'" style="color: #999;" />
      <?php } ?>
      <select name="filter_category_id">
        <option value="0"><?php echo $text_category; ?></option>
        <?php foreach ($categories as $category_1) { ?>
        <?php if ($category_1['category_id'] == $filter_category_id) { ?>
        <option value="<?php echo $category_1['category_id']; ?>" selected="selected"><?php echo $category_1['name']; ?></option>
        <?php } else { ?>
        <option value="<?php echo $category_1['category_id']; ?>"><?php echo $category_1['name']; ?></option>
        <?php } ?>
        <?php foreach ($category_1['children'] as $category_2) { ?>
        <?php if ($category_2['category_id'] == $filter_category_id) { ?>
        <option value="<?php echo $category_2['category_id']; ?>" selected="selected">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $category_2['name']; ?></option>
        <?php } else { ?>
        <option value="<?php echo $category_2['category_id']; ?>">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $category_2['name']; ?></option>
        <?php } ?>
        <?php foreach ($category_2['children'] as $category_3) { ?>
        <?php if ($category_3['category_id'] == $filter_category_id) { ?>
        <option value="<?php echo $category_3['category_id']; ?>" selected="selected">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $category_3['name']; ?></option>
        <?php } else { ?>
        <option value="<?php echo $category_3['category_id']; ?>">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $category_3['name']; ?></option>
        <?php } ?>
        <?php } ?>
        <?php } ?>
        <?php } ?>
      </select>
      <?php if ($filter_sub_category) { ?>
      <input type="checkbox" name="filter_sub_category" value="1" id="sub_category" checked="checked" />
      <?php } else { ?>
      <input type="checkbox" name="filter_sub_category" value="1" id="sub_category" />
      <?php } ?>
      <label for="sub_category"><?php echo $text_sub_category; ?></label>
    </p>
    <?php if ($filter_description) { ?>
    <input type="checkbox" name="filter_description" value="1" id="description" checked="checked" />
    <?php } else { ?>
    <input type="checkbox" name="filter_description" value="1" id="description" />
    <?php } ?>
    <label for="description"><?php echo $entry_description; ?></label>
  </div>
  <div class="buttons">
    <div class="right"><a id="button-search" class="button"><span><?php echo $button_search; ?></span></a></div>
  </div>
  <h2><?php echo $text_search; ?></h2>
  <?php if ($products) { ?>
  <div class="product-filter">
    <div class="display"><b><?php echo $text_display; ?></b> <?php echo $text_list; ?> <b>/</b> <a onclick="display('grid');"><?php echo $text_grid; ?></a></div>
    <div class="limit"><?php echo $text_limit; ?>
      <select onchange="location = this.value;">
        <?php foreach ($limits as $limits) { ?>
        <?php if ($limits['value'] == $limit) { ?>
        <option value="<?php echo $limits['href']; ?>" selected="selected"><?php echo $limits['text']; ?></option>
        <?php } else { ?>
        <option value="<?php echo $limits['href']; ?>"><?php echo $limits['text']; ?></option>
        <?php } ?>
        <?php } ?>
      </select>
    </div>
    <div class="sort"><?php echo $text_sort; ?>
      <select onchange="location = this.value;">
        <?php foreach ($sorts as $sorts) { ?>
        <?php if ($sorts['value'] == $sort . '-' . $order) { ?>
        <option value="<?php echo $sorts['href']; ?>" selected="selected"><?php echo $sorts['text']; ?></option>
        <?php } else { ?>
        <option value="<?php echo $sorts['href']; ?>"><?php echo $sorts['text']; ?></option>
        <?php } ?>
        <?php } ?>
      </select>
    </div>
  </div>
  <div class="product-compare"><a href="<?php echo $compare; ?>" id="compare_total"><?php echo $text_compare; ?></a></div>
  <div class="product-list">
    <?php foreach ($products as $product) { ?>
    <div>
      <?php if ($product['thumb']) { ?>
      <div class="image"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" /></a></div>
      <?php } ?>
      <div class="name"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></div>
      <div class="description"><?php echo $product['description']; ?></div>
      <?php if ($product['price']) { ?>
      <div class="price">
        <?php if (!$product['special']) { ?>
        <?php echo $product['price']; ?>
        <?php } else { ?>
        <span class="price-old"><?php echo $product['price']; ?></span> <span class="price-new"><?php echo $product['special']; ?></span>
        <?php } ?>
        <?php if ($product['tax']) { ?>
        <br />
        <span class="price-tax"><?php echo $text_tax; ?> <?php echo $product['tax']; ?></span>
        <?php } ?>
      </div>
      <?php } ?>
      <?php if ($product['rating']) { ?>
      <div class="rating"><img src="catalog/view/theme/default/image/stars-<?php echo $product['rating']; ?>.png" alt="<?php echo $product['reviews']; ?>" /></div>
      <?php } ?>
      <div class="cart"><a onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button"><span><?php echo $button_cart; ?></span></a></div>
      <div class="wishlist"><a onclick="addToWishList('<?php echo $product['product_id']; ?>');"><?php echo $button_wishlist; ?></a></div>
      <div class="compare"><a onclick="addToCompare('<?php echo $product['product_id']; ?>');"><?php echo $button_compare; ?></a></div>
    </div>
    <?php } ?>
  </div>
  <div class="pagination"><?php echo $pagination; ?></div>
  <?php } else { ?>
  <div class="content"><?php echo $text_empty; ?></div>
  <?php }?>
  <?php echo $content_bottom; ?></div>
<script type="text/javascript"><!--
$('#content input[name=\'filter_name\']').keydown(function(e) {
	if (e.keyCode == 13) {
		$('#button-search').trigger('click');
	}
});

$('#button-search').bind('click', function() {
	url = 'index.php?route=product/search';
	
	var filter_name = $('#content input[name=\'filter_name\']').attr('value');
	
	if (filter_name) {
		url += '&filter_name=' + encodeURIComponent(filter_name);
	}

	var filter_category_id = $('#content select[name=\'filter_category_id\']').attr('value');
	
	if (filter_category_id > 0) {
		url += '&filter_category_id=' + encodeURIComponent(filter_category_id);
	}
	
	var filter_sub_category = $('#content input[name=\'filter_sub_category\']:checked').attr('value');
	
	if (filter_sub_category) {
		url += '&filter_sub_category=true';
	}
		
	var filter_description = $('#content input[name=\'filter_description\']:checked').attr('value');
	
	if (filter_description) {
		url += '&filter_description=true';
	}

	location = url;
});

function display(view) {
	if (view == 'list') {
		$('.product-grid').attr('class', 'product-list');
		
		$('.product-list > div').each(function(index, element) {
			html  = '<div class="right">';
			html += '  <div class="cart">' + $(element).find('.cart').html() + '</div>';
			html += '  <div class="wishlist">' + $(element).find('.wishlist').html() + '</div>';
			html += '  <div class="compare">' + $(element).find('.compare').html() + '</div>';
			html += '</div>';			
			
			html += '<div class="left">';
			
			var image = $(element).find('.image').html();
			
			if (image != null) { 
				html += '<div class="image">' + image + '</div>';
			}
			
			var price = $(element).find('.price').html();
			
			if (price != null) {
				html += '<div class="price">' + price  + '</div>';
			}
						
			html += '  <div class="name">' + $(element).find('.name').html() + '</div>';
			html += '  <div class="description">' + $(element).find('.description').html() + '</div>';
			
			var rating = $(element).find('.rating').html();
			
			if (rating != null) {
				html += '<div class="rating">' + rating + '</div>';
			}
				
			html += '</div>';

						
			$(element).html(html);
		});		
		
		$('.display').html('<b><?php echo $text_display; ?></b> <?php echo $text_list; ?> <b>/</b> <a onclick="display(\'grid\');"><?php echo $text_grid; ?></a>');
		
		$.cookie('display', 'list'); 
	} else {
		$('.product-list').attr('class', 'product-grid');
		
		$('.product-grid > div').each(function(index, element) {
			html = '';
			
			var image = $(element).find('.image').html();
			
			if (image != null) {
				html += '<div class="image">' + image + '</div>';
			}
			
			html += '<div class="name">' + $(element).find('.name').html() + '</div>';
			html += '<div class="description">' + $(element).find('.description').html() + '</div>';
			
			var price = $(element).find('.price').html();
			
			if (price != null) {
				html += '<div class="price">' + price  + '</div>';
			}	
					
			var rating = $(element).find('.rating').html();
			
			if (rating != null) {
				html += '<div class="rating">' + rating + '</div>';
			}
						
			html += '<div class="cart">' + $(element).find('.cart').html() + '</div>';
			html += '<div class="wishlist">' + $(element).find('.wishlist').html() + '</div>';
			html += '<div class="compare">' + $(element).find('.compare').html() + '</div>';
			
			$(element).html(html);
		});	
					
		$('.display').html('<b><?php echo $text_display; ?></b> <a onclick="display(\'list\');"><?php echo $text_list; ?></a> <b>/</b> <?php echo $text_grid; ?>');
		
		$.cookie('display', 'grid');
	}
}

view = $.cookie('display');

if (view) {
	display(view);
} else {
	display('list');
}
//--></script> 
<?php echo $footer; ?>